from common.readpath import ReadPath
import configparser

# 获取账号配置文件路径
accountinfo_path = ReadPath().get_accountinfo_path()
# 调用外部的读取配置文件的方法
config = configparser.ConfigParser()
config.read(accountinfo_path, encoding='utf-8')


class ReadConfig():

    # 读取web端配置信息
    def get_http(self, name):
        value = config.get('HTTP', name)
        return value

    # 读取DATABASE配置信息
    def get_mysql(self, name):
        value = config.get('DATABASE', name)
        return value

    # 读取测试账号信息
    def get_account(self, name):
        value = config.get('LONIN_ACCOUNT', name)
        return value


if __name__ == '__main__':  # 测试读取配置文件的方法是否可用
    print('HTTP中的browsertype值为:', ReadConfig().get_http('browsertype'))
    print('HTTP中的url值为:', ReadConfig().get_http('url'))
    print('DATABASE的port值为:', ReadConfig().get_mysql('port'))
    print('LONIN_ACCOUNT的username值为:', ReadConfig().get_account('username'))
    print('LONIN_ACCOUNT的password值为:', ReadConfig().get_account('password'))
